/*
int
parse 5 5
parse 2+3 5
parse '2*3' 6
parse '2+3+4' 9
parse '2*3+4' 10
parse '2+3*4' 14
parse '2*3*4' 24
parse 456 456
parse '53*(13+75)' 4664
parse ' 456 + 123 * ( 543 + 7 * (987 + 2) + 6) ' 919512
noparse x Sum 1
*/

# Bryan Ford"s trivial grammar with integers and spacing:

Sum :: int ← Space a:Additive → a
Additive <- m:Multitive Plus a:Additive { m + a } / m:Multitive -> m
Multitive <- p:Primary Times m:Multitive { p * m } / p:Primary -> p
Primary <- Left a:Additive Right -> a / d:Decimal -> d
Decimal ← Digits1 Space { atoi(ref_ptr(ref())) }
Digits1 :: void ← Digit Digits1 / Digit
Digit <- "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"

Left ← "(" Space
Right ← ")" Space
Plus ← "+" Space
Times ← "*" Space
Space ← " " Space / ε
